﻿using System;
using System.Runtime.InteropServices;
using ZWFrameWork;
using DWORD = System.UInt32;
using WORD = System.UInt16;
using SCORE = System.Int64;
using SCOREEX = System.Double;

public class GAME_MSG_CODE
{
    /// 登录信息
    public const int MDM_GR_LOGON = 1;

    /// 登录信息
    /// 登录模式
    public const int SUB_GR_LOGON_USERID = 1;

    /// ID登录
    public const int SUB_GR_LOGON_MOBILE = 2;

    /// 手机登录
    public const int SUB_GR_LOGON_ACCOUNTS = 3;

    /// 帐户登录
    /// 登录结果
    public const int SUB_GR_LOGON_SUCCESS = 100;

    /// 登录成功
    public const int SUB_GR_LOGON_FAILURE = 101;

    /// 登录失败
    public const int SUB_GR_LOGON_FINISH = 102;

    /// 登录完成
    /// 升级提示
    public const int SUB_GR_UPDATE_NOTIFY = 200;


    /// 升级提示
    public const int MDM_GR_USER = 3;

    //用户动作
    public const int SUB_GR_USER_RULE = 1;

    public const int SUB_GR_USER_WAIT_DISTRIBUTE = 12;

    //用户状态
    public const int SUB_GR_REQUEST_FAILURE = 103;

    //银行命令
    public const int MDM_GR_INSURE = 5; //用户信息

    //命令
    public const int SUB_GR_ENABLE_INSURE_REQUEST = 1; //开通银行
    public const int SUB_GR_QUERY_INSURE_INFO = 2; //查询银行
    public const int SUB_GR_SAVE_SCORE_REQUEST = 3; //存款操作
    public const int SUB_GR_TAKE_SCORE_REQUEST = 4; //取款操作
    public const int SUB_GR_TRANSFER_SCORE_REQUEST = 5; //取款操作
    public const int SUB_GR_QUERY_USER_INFO_REQUEST = 6; //查询用户

    public const int SUB_GR_USER_INSURE_INFO = 100; //银行资料
    public const int SUB_GR_USER_INSURE_SUCCESS = 101; //银行成功
    public const int SUB_GR_USER_INSURE_FAILURE = 102; //银行失败
    public const int SUB_GR_USER_TRANSFER_USER_INFO = 103; //用户资料
    public const int SUB_GR_USER_INSURE_ENABLE_RESULT = 104; //开通结果


    ///框架命令
    public const int MDM_GF_FRAME = 100; //框架命令

    //用户命令
    public const int SUB_GF_GAME_OPTION = 1; //游戏配置
    public const int SUB_GF_USER_READY = 2; //用户准备
    public const int SUB_GF_LOOKON_CONFIG = 3; //旁观配置
    public const int SUB_GF_DISTRIBUTE_AFFIRM = 4; //分组确认

    //聊天命令
    public const int SUB_GF_USER_CHAT = 10; //用户聊天
    public const int SUB_GF_USER_EXPRESSION = 11; //用户表情
    public const int SUB_GF_USER_VOICE = 12; //用户语音

    //系统消息
    public const int SUB_GF_SYSTEM_MESSAGE = 200; //系统消息
    public const int SUB_GF_ACTION_MESSAGE = 201; //动作消息
}


//登录成功
[Serializable]
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode, Pack = 1)]
public struct CMD_GR_LogonSuccess
{
    public DWORD dwUserRight; //用户权限
    public DWORD dwMasterRight; //管理权限
}

//服务端返回字符
[Serializable]
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode, Pack = 1)]
public struct tagPromptString_G
{
    public DWORD wMoudleIndex;
    public Int32 lStringIndex;
    public byte cbFormatCount;
}

[Serializable]
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode, Pack = 1)]
public struct tagFormatString_G
{
    [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 32)]
    public string szFormatString;
}

//////
//发包结构
//////
//回包结构
//请求失败
[Serializable]
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode, Pack = 1)]
public struct CMD_GR_RequestFailure
{
    public int lErrorCode; //错误代码

    public tagPromptString_G tagPromptString; //提示语
    // {k = "szDescribeString", t = "string", s = 512}									//描述信息
}

//用户规则
[Serializable]
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode, Pack = 1)]
public struct CMD_GR_UserRule
{
    public byte cbRuleMask; //规则掩码
    public WORD wMinWinRate; //最低胜率
    public WORD wMaxFleeRate; //最高逃率
    public SCORE lMaxGameScore; //最高分数
    public SCORE lMinGameScore; //最低分数
}

//登录失败
[Serializable]
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode, Pack = 1)]
public struct CMD_GR_LogonFailureEx
{
    public int lErrorCode; //错误代码
    public WORD wKindID; //游戏类型 错误码为100时使用
    public WORD wServerID; //服务器ID 错误码为100时使用

    public tagPromptString_G PromptString; //提示语
    // {k = "szDescribeString", t = "string",s = 128},						//描述消息
}

//数据扩展
[Serializable]
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode, Pack = 1)]
public struct tagDataDescribe

{
    public WORD wDataSize; //数据大小
    public WORD wDataDecribe; //数据描述
}


//银行资料
[Serializable]
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode, Pack = 1)]
public struct CMD_GR_S_UserInsureInfo
{
    public byte cbActivityGame; //游戏动作
    public byte cbEnjoinTransfer; //转账开关
    public WORD wRevenueTake; //税收比例
    public WORD wRevenueTransfer; //税收比例
    public WORD wRevenueTransferMember; //税收比例
    public WORD wServerID; //房间标识
    public double lUserScore; //用户金币
    public double lUserInsure; //银行金币
    public double lTransferPrerequisite; //转账条件
    public DWORD dwUserRight; //用户权限

    [MarshalAs(UnmanagedType.ByValArray, SizeConst = Protocal.LEN_BANKEROP_BT)]
    public double[] lBankOPButtionArray; //银行存取操作按钮数组//前3位为3个按钮数值 第4位为最大全存数 第5位为最大全取数
}

//银行失败
[Serializable]
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode, Pack = 1)]
public struct CMD_GR_S_UserInsureFailure
{
    //游戏动作
    public byte cbActivityGame;

    //错误代码
    public int lErrorCode;

    //描述消息
    public tagPromptString_G PromptString; //提示语
    // public szDescribeString", t = "string"//[[, s = 128]]},
}

//用户聊天
[Serializable]
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode, Pack = 1)]
public struct CMD_GF_C_UserChat
{
    public WORD wChatLength; //内容长度
    public DWORD dwChatColor; //颜色
    public DWORD dwTargerUserID; //目标用户id

    [MarshalAs(UnmanagedType.ByValTStr, SizeConst = Protocal.LEN_USER_CHAT)]
    public string szChatString; //聊天内容
}

//用户表情
[Serializable]
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode, Pack = 1)]
public struct CMD_GF_C_UserExpression
{
    public WORD wItemIndex; //表情索引
    public DWORD dwTargerUserID; //目标用户id
}

//////
//回包结构
//用户聊天
[Serializable]
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode, Pack = 1)]
public struct CMD_GF_S_UserChat
{
    public WORD wChatLength; //内容长度
    public DWORD dwChatColor; //颜色
    public DWORD dwSendUserID; //发送用户id

    public DWORD dwTargerUserID; //接收用户id

    //这里不能限定读取长度，会异常。。。, s = yl.LEN_USER_CHAT
    [MarshalAs(UnmanagedType.ByValTStr, SizeConst = Protocal.LEN_USER_CHAT)]
    public string szChatString; //聊天内容
}

//用户表情
[Serializable]
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode, Pack = 1)]
public struct CMD_GF_S_UserExpression
{
    public WORD wItemIndex; //表情索引
    public WORD dwSendUserID; //发送用户id
    public DWORD dwTargerUserID; //目标用户id
}

[Serializable]
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode, Pack = 1)]
public struct CMD_CM_SystemMessage
{
    public WORD wType; //消息类型
    public tagPromptString_G PromptString;
}

[Serializable]
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode, Pack = 1)]
// 用户信息
public struct tagMobileUserInfoHead
{
    // 用户属性
    public DWORD dwGameID; // 游戏 I D
    public DWORD dwUserID; // 用户 I D

    // 头像信息
    public WORD wFaceID; // 头像索引
    public DWORD dwCustomID; // 自定标识

    // 用户属性
    public byte cbGender; // 用户性别
    public byte cbMemberOrder; // 会员等级

    // 用户状态
    public WORD wTableID; // 桌子索引
    public WORD wChairID; // 椅子索引
    public byte cbUserStatus; // 用户状态

    // 积分信息
    public double lScore; // 用户分数
    public double lIngot; // 用户元宝
    public double dBeans; // 用户游戏豆
    public double lRechargeAmount; // 充值分数

    // 游戏信息
    public DWORD dwWinCount; // 胜利盘数
    public DWORD dwLostCount; // 失败盘数
    public DWORD dwDrawCount; // 和局盘数
    public DWORD dwFleeCount; // 逃跑盘数
    public DWORD dwExperience; // 用户经验
    public SCORE lIntegralCount; // 积分总数

    // 代理信息
    public DWORD dwAgentID; // 代理 I D

    public DWORD dwIpAddress; // ip地址
}

//  用户积分
[Serializable]
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode, Pack = 1)]
public struct tagMobileUserScore
{
    // 积分信息
    public double lScore; // 用户分数
    public double dBeans; // 用户游戏豆

    // 输赢信息
    public DWORD dwWinCount; // 胜利盘数
    public DWORD dwLostCount; // 失败盘数
    public DWORD dwDrawCount; // 和局盘数
    public DWORD dwFleeCount; // 逃跑盘数

    // 全局信息
    public DWORD dwExperience; // 用户经验
}

// 桌子状态
[Serializable]
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode, Pack = 1)]
public struct tabTableStatus
{
    public byte cbTableLock; // 锁定标识
    public byte cbPlayStatus; // 游戏标识
    public int lCellScore; // 单元积分
}

// 用户状态
[Serializable]
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode, Pack = 1)]
public struct CMD_GR_ConfigServer
{
    public WORD wTableCount; // 桌子数目
    public WORD wChairCount; // 椅子数目
    public WORD wServerType; // 房间类型
    public DWORD dwServerRule; // 房间规则

    public double lEnterScore; // 最低入场分
    public double lMaxEnterScore; // 最高入场分(0无效)
}

//房间配置

[Serializable]
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode, Pack = 1)]
public struct tagUserStatus
{
    public WORD wTableID; // 桌子索引
    public WORD wChairID; // 椅子索引
    public byte cbUserStatus; // 用户状态
}

//防作弊场，房间匹配过程完整，等待开始游戏
[Serializable]
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode, Pack = 1)]
public struct tagAntiCheatWaitStart
{
    public byte cbLeftTime;
}